package com.food.model;

import java.time.LocalDateTime;
import java.util.Arrays;

public class UserProfile {
    private Integer profileId;
    private Integer userId;
    private String name = "";
    private String gender = GENDER_UNKNOWN;
    private Integer age = 0;
    private Double height = 0.0;
    private Double weight = 0.0;
    private String activityLevel = DEFAULT_ACTIVITY_LEVEL;
    private LocalDateTime updatedAt;

    public static final String GENDER_UNKNOWN = "其他";
    public static final String GENDER_MALE = "男";
    public static final String GENDER_FEMALE = "女";
    public static final String[] VALID_GENDERS = {GENDER_MALE, GENDER_FEMALE, GENDER_UNKNOWN};

    public static final String DEFAULT_ACTIVITY_LEVEL = "中等";
    public static final String[] VALID_ACTIVITY_LEVELS = {"低", "中等", "高"};

    public UserProfile() {
    }

    public Integer getProfileId() {
        return profileId;
    }

    public void setProfileId(Integer profileId) {
        this.profileId = profileId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }

    public String getActivityLevel() {
        return activityLevel;
    }

    public void setActivityLevel(String activityLevel) {
        this.activityLevel = activityLevel;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public boolean isValid() {
        if (gender != null && !Arrays.asList(VALID_GENDERS).contains(gender)) {
            return false;
        }
        
        if (activityLevel != null && !Arrays.asList(VALID_ACTIVITY_LEVELS).contains(activityLevel)) {
            return false;
        }
        
        if (age != null && (age < 0 || age > 150)) {
            return false;
        }
        
        if (height != null && (height < 0 || height > 300)) {
            return false;
        }
        
        if (weight != null && (weight < 0 || weight > 500)) {
            return false;
        }
        
        return true;
    }
} 